package com.zgw.his.design.model;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.core.internal.resources.Resource;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;

/**
 * 用于与资源库绑定
 * */
@SuppressWarnings({ "restriction", "unused" })
public abstract class MedicalResource {
	// ================================================
	// 资源三种状态 修改‘亲增‘删除
	// ===================================================
	public static final int STATE_UPDATE = 1;
	public static final int STATE_NEW = 2;
	public static final int STATE_DEL = 3;
	public static final int STATE_NOMAL = 4;

	// ================================================
	// 资源持久化属性 KEY
	// ===================================================
	public static final String KEY_VERSION = "SOURCE_VERSION";
	public static final String KEY_NUMBER = "SOURCE_NUMBER";
	public static final String KEY_STATE = "SOURCE_STATE";

	// ================================================
	// 数据绑定
	// ===================================================
	private static final String DATA_DEFAULT_KEY = "DATA_DEFAULT_KEY";

	public Map<String, Object> datas = new HashMap<String, Object>();

	public Object getData() {
		return datas.get(DATA_DEFAULT_KEY);
	}

	public void setData(Object obj) {
		datas.put(DATA_DEFAULT_KEY, obj);
	}

	public abstract int getState();

	public abstract Resource getResource();

	public static final String qualifier = "all";

	public void setPersistentProperty(String key, String value)
			throws CoreException {
		Resource resource = getResource();
		QualifiedName k = new QualifiedName(qualifier, key);
		resource.setPersistentProperty(k, value);
	}

	public String getPersistentProperty(String key) throws CoreException {
		Resource resource = getResource();
		QualifiedName k = new QualifiedName(qualifier, key);
		return resource.getPersistentProperty(k);
	}
}
